//
//  MNDTransactionRecordCell.m
//  minidai
//
//  Created by Steven.Yung on 2017/5/17.
//  Copyright © 2017年 迷你金服. All rights reserved.
//

#import "MNDTransactionRecordCell.h"
#import <SDWebImage/UIImageView+WebCache.h>

@interface MNDTransactionRecordCell ()

@property (weak, nonatomic) IBOutlet UIImageView *cellicon;
@property (weak, nonatomic) IBOutlet UILabel *transactionTitleLabel;
@property (weak, nonatomic) IBOutlet UILabel *transactionTimeLabel;
@property (weak, nonatomic) IBOutlet UILabel *transactionMoneyLabel;
@property (weak, nonatomic) IBOutlet UILabel *transactionBalanceLabel;


@end

@implementation MNDTransactionRecordCell

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

- (void)setModel:(MNDTransactionRecordModel *)model {
    
    _model = model;
    
    if (model.transaction_remark.length > 0 && ![model.transaction_title isEqualToString:model.transaction_remark]) {
        self.transactionTitleLabel.text = [NSString stringWithFormat:@"%@ - %@", model.transaction_title, model.transaction_remark];
    } else {
        self.transactionTitleLabel.text = model.transaction_title;
    }
    
    if ([model.transaction_money containsString:@"-"]) {
        
        self.transactionMoneyLabel.text = [NSString stringWithFormat:@"-￥%@", [model.transaction_money stringByReplacingOccurrencesOfString:@"-" withString:@""]];
    } else {
        self.transactionMoneyLabel.text = [NSString stringWithFormat:@"+￥%@", model.transaction_money];
    }
    
    self.transactionTimeLabel.text = model.transaction_time;
    self.transactionBalanceLabel.text = [NSString stringWithFormat:@"余额: ￥%@", model.transaction_user_amount];
    
    [self.cellicon sd_setImageWithURL: [NSURL URLWithString:model.transaction_img]
                     placeholderImage: [UIImage imageNamed:@"transaction_record_placeholder"]];
}

@end
